cmake_minimum_required(VERSION 3.10.2)
project(LDBTest)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-std=c++1y -fno-rtti -fvisibility=default -D_GNU_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fPIC -fpic -ffunction-sections -D_GLIBC_MOCK")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -ldl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=0 -fpermissive")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")

include_directories(${CMAKE_SOURCE_DIR}/utils_native/base/include)
include_directories(${CMAKE_SOURCE_DIR}/utils_native/safwk/native/include)
set(MOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../mock)
set(KV_STORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../kv_store)
include_directories(${MOCK_DIR}/src/)
include_directories(${MOCK_DIR}/sqlite/include)
include(${MOCK_DIR}/include/CMakeLists.txt OPTIONAL)
include(${KV_STORE_DIR}/interfaces/CMakeLists.txt OPTIONAL)
include(${CMAKE_CURRENT_SOURCE_DIR}/include/CMakeLists.txt OPTIONAL)
include_directories(${CMAKE_SOURCE_DIR}/googletest/googletest/include)
include_directories(${CMAKE_SOURCE_DIR}/googletest/googlemock/include)

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/ mainSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/service serviceSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/client clientSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../data_object/frameworks/innerkitsimpl/test/unittest localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../kv_store/frameworks/innerkitsimpl/kvdb/test localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../kv_store/frameworks/common/test localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/unittest remoteTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/framework/test localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/adapter/communicator/test/unittest remoteTestSrc)
#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/app/test/unittest remoteTestSrc)
#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/app/test/moduletest remoteTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/service/test/mock remoteTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/service/test remoteTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../datamgr_service/services/distributeddataservice/service/test/data_share remoteTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../preferences/test/native/unittest localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../relational_store/test/native/dataability/unittest localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../relational_store/test/native/rdb/unittest localTestSrc)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../relational_store/test/native/rdb_data_share_adapter/unittest localTestSrc)

set(links secure mock relational_store data_share preferences jsoncpp crypto distributeddb data_object app adapter svcFwk kvdb service)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

enable_testing()
add_executable(LDBTest ${remoteTestSrc} ${localTestSrc} ${mainSrc} ${serviceSrc})
target_link_libraries(LDBTest ${links} gtest_main gcov)

add_executable(LDBLocalTest ${localTestSrc} ${mainSrc} ${clientSrc})
target_link_libraries(LDBLocalTest ${links} gtest_main gcov)
#include(GoogleTest)
#gtest_discover_tests(${TEST_BINARY})